<?php

// phpMyRealty 3
//
// File Name: index.php
// File Location : ./
//
// Copyright (c)2009 phpMyRealty.com
//
// e-mail: support@phpMyRealty.com

// All materials and software are copyrighted by phpMyRealty.com
// under British, US and International copyright law. All rights reserved.
// No part of this code may be reproduced, sold, distributed
// or otherwise used in whole or in part without prior written permission.

// Include configuration file and general functions
define('PMR', 'true');

include ( './config.php' );

// Error reporting function
function initial_error ( $errortype, $errormessage = '' ) {
 echo '<strong>' . $errortype . '</strong><br /><br />' . $errormessage; exit(0);
}

// Check the md5 hash of the encoded file to be sure it is uploaded correctly.
// if (md5_file( PATH . '/admin/functions.php' ) != 'a4a04572a2edbef7141f43aadde95950' && md5_file( PATH . '/admin/functions.php' ) != '8627ef22937088d1e4c47debc7c24ba9') initial_error ('Initialization Error', 'The encoded files must be uploaded in binary mode. Please, contact support to have this resolved.');

include ( PATH . '/defaults.php' );

// Check the installation folders and ask to remove those if exist
if (file_exists( PATH . '/install/install.php' )) error ('Initialization Error', 'The /install folder must be removed after you have done the install.');
if (file_exists( PATH . '/docs/installation.txt' )) error ('Initialization Error', 'The /docs folder must be removed after you have done the install or upgrade.');

// Destroy user/admin session if we logout
if (isset($_GET['req']) && $_GET['req'] == 'logout') $session->destroy();

// ----------------------------------------------------------------------
// INDEX PAGE SECTION

// Title tag content
$title = $conf['website_name_short'];

// Disable if you do not have the top search form on the index page or
// have no 3 level locations dropdowns in the top search form
$initAjax = TRUE;

if ($conf['main_map'] == 'ON')
	$initiate_maps = 'ON';

if (isset($initAjax) && $initAjax)
 include ( PATH . '/includes/ajaxDropdowns.php');

// Disable this if you do not use /box-maps.php on the index.php page
// $initiate_maps = 'ON';

// Template header
include ( PATH . '/templates/' . $cookie_template . '/header.php' );

// Unsetting the search caches
$session->varunset('usersearchvariables');
$session->varunset('listingsearchvariables');

$session->varunset('usersearchvariablespage');
$session->varunset('listingsearchvariablespage');

if (empty($main_search_tabs) || !is_array($main_search_tabs)) {
    $main_search_tabs = array(
        'tab-search',
        'tab-propertyType',
        'tab-priceRange',
    );
}

// Tabbed box with Search, Property Types and Price Range
if ($conf['main_search'] == 'ON')
{

	/*
    $selected = ' class"selected"';
    echo '<ul id="searchtabs" class="indexdynamicmenu">'; 
    foreach ($main_search_tabs as $main_search_tab) {
        switch ($main_search_tab) {
        case 'tab-search':
            echo '<p><a href="#" rel="tab-search"'.$selected.'><span class="tab_title">' . $lang['Menu_Search'] . '</span></a></p>';
            break;
        case 'tab-propertyType':
            echo '<p><a href="#" rel="tab-propertyType"'.$selected.'><span class="tab_title">' . $lang['Module_Property_Type'] . '</span></a></p>';
            break;
        case 'tab-priceRange':
            echo '<p><a href="#" rel="tab-priceRange"'.$selected.'><span class="tab_title">' . $lang['Search_Price_Range'] . '</span></a></p>';
            break;
        }
        $selected = '';
    }
    echo '
	         </ul>
	
	        <div class="searchtab">
	';
	*/
	
	// Include Search Form box
	//if (in_array('tab-search', $main_search_tabs))
	include ( PATH . '/templates/' . $cookie_template . '/searchFormMain.php' );
	
	// Include Property Types box
    //if (in_array('tab-propertyType', $main_search_tabs))
	//include ( PATH . '/box-types.php' );
	
	// Include Price Range box
    //if (in_array('tab-priceRange', $main_search_tabs))
	//include ( PATH . '/box-prices.php' );
	
	// Javascript required for tabbed boxes with search forms to appear
	/*
	echo '
		</div>
	         <script type="text/javascript">
	          var searchtabs=new ddtabcontent("searchtabs")
	          searchtabs.setpersist(true)
	          searchtabs.setselectedClassTarget("link")
	          searchtabs.init()
	         </script><br />
	';
	*/
}

// Include SlideShow box
//if ($conf['slideshow_main'] == 'ON')
//	include ( PATH . '/box-slideshow.php' );

// Include Featured Listings box
if ($conf['featured_listings'] == 'ON')
	include ( PATH . '/box-featured.php' );

// Include Featured Agents box
if ($conf['featured_agents'] == 'ON')
	include ( PATH . '/box-featured-agents.php' );

// All Agents
if ($conf['all_listings'] == 'ON')
	include ( PATH . '/box-all-listings.php' );

// All Agents
if ($conf['all_agents'] == 'ON')
	include ( PATH . '/box-all-agents.php' );

// Tabbed box with Most Visited, Recent Listings, Recent Agents and Recently Visited Listings
if ($conf['recent_listings'] == 'ON')
{
	echo '
	        <ul id="listingtabs" class="indexdynamicmenu">
	         <p><a href="#" rel="tab-recent" class="selected"><span class="tab_title">' . $lang['Module_Recent_Listings'] . '</span></a></p>
	         <p><a href="#" rel="tab-recentAgents"><span class="tab_title">' . $lang['Module_Recent_Agents'] . '</span></a></p>
	         <p><a href="#" rel="tab-mostvisited"><span class="tab_title">' . $lang['Module_Most_Visited'] . '</span></a></p>
	         <p><a href="#" rel="tab-visited"><span class="tab_title">' . $lang['Listings_Visited'] . '</span></a></p>
	        </ul>
	
	        <div class="listingstab">
	';
	
	// Include Most Visited Listings box
	include ( PATH . '/box-mostvisited.php' );
	
	// Include Recent Agents box
	include ( PATH . '/box-recent-agents.php' );
	
	// Include Recent Listings box
	include ( PATH . '/box-recent.php' );
	
	// Include Recently Visited Listings
	include ( PATH . '/box-visited.php' );
	
	// Javascript required for tabbed boxes with listings to appear
	echo '
		</div>
	         <script type="text/javascript">
	          var listingtabs=new ddtabcontent("listingtabs")
	          listingtabs.setpersist(true)
	          listingtabs.setselectedClassTarget("link")
	          listingtabs.init()
	         </script>
	    <br />
	';
}

//Include Google Maps box
if ($conf['main_map'] == 'ON')
	include ( PATH . '/box-maps.php' );

// Include CRON jobs
include ( PATH . '/includes/functions/cron.php' );

// Template footer
include ( PATH . '/templates/' . $cookie_template . '/footer.php' );

?>